package controller

import (
	"github.com/gin-gonic/gin"
)

const (
	CODE_SUCC        = 0
	CODE_FAIL_PARAM  = 1001
	CODE_FAIL_SERVER = 1099
)

func SuccResp(msg string, data interface{}) gin.H {
	if msg == "" {
		msg = "请求成功"
	}
	if data != nil {
		return gin.H{"code": CODE_SUCC, "message": msg, "data": data}
	} else {
		return gin.H{"code": CODE_SUCC, "message": msg}
	}
}

func FailParamResp() gin.H {
	return gin.H{"err_code": CODE_FAIL_PARAM, "error": "请求参数错误!"}
}

func FailServerResp() gin.H {
	return gin.H{"err_code": CODE_FAIL_SERVER, "error": "服务器开小差了!"}
}
